package com.yssw.onlinechat.service;

import javax.websocket.Session;
import javax.websocket.server.PathParam;
import java.io.IOException;

/**
 * @Author KnockingFarmers
 * @Date 2023/3/8 17:13
 * @PackageName:com.online.onlinecustomerservice.service
 * @ClassName: WebSocketService
 * @Description: TODO
 * @Version 1.0
 */
public interface WebSocketService {

    /**
     * 发送异常时调用
     *
     * @param session
     * @param error
     */
    void onError(Session session, Throwable error) throws IOException;

    /**
     * 收到消息时调用
     *
     * @param message
     * @param session
     * @param userName
     * @throws IOException
     */
    void onMessage(String message, Session session, String userName) throws IOException;

    /**
     * 连接关闭时调用
     */
    void onClose() throws IOException;

    /**
     * 有新连接时调用
     *
     * @param session
     * @param userName
     * @throws IOException
     */
    void onOpen(Session session, @PathParam("userName") String userName) throws IOException;

}
